// 公共头部
import myHeader from "/pages/headerfoot/pages/header.vue";
//打帮赛方法
import hitmatchcommon from '@/common/hitmatchcommon.js';
//cache缓存
import Cache from '@/utils/cache.js';
//基础
import Base from '@/common/base.js'
//搜索
import uSearchBar from "/uni_modules/uni-search-bar/components/uni-search-bar/uni-search-bar.vue";
//图标
import uIcons from "/uni_modules/uni-icons/components/uni-icons/uni-icons.vue";


export default {
	components: {
		myHeader,
		uSearchBar,
		uIcons
	},
	data() {
		return {
			make_id: '', //赛事ID
			list: [], //列表
			Base: Base, //基础
			frame: false, //弹出框
			list:[],//赛事项目列表
		}
	},
	onLoad(options = '') {
		var that = this;
		console.log(options);
		if (options.id) {
			that.make_id = options.id;
			that.getMakeProjectListLib(); //获取项目
		}
	},
	// 1.发送给朋友
		onShareAppMessage(e) {
			let projectid = e.target.dataset.projectid // 项目ID
			 return {
			 	title: "打榜赛"+projectid,
			 	path: "/pages/hitgame/pages/hitgameindex?id="+projectid,
			 	imageUrl: 'https://www.iiscchina.com/wp-content/uploads/2023/07/qtmf.png',
			 }
		},
	methods: {
		//查询搜索
		search(res) {
			uni.showToast({
				title: '搜索：' + res.value,
				icon: 'none'
			})
		},
		//弹出项目选择
		applybattle(type = '') {
			var that = this;
			console.log(type);
			that.frame = true; //弹出框
		},
		//关闭弹出项目选择
		close() {
			var that = this;
			that.frame = false; //弹出框
		},
		//弹出规则
		rulebattle() {
			uni.showModal({
				title: '对战规则',
				content: '弹框同时使用确定取消时，需注意不同平台的确认取消按钮位置不同。在微信、H5中，确认按钮默认在右边。在App中，iOS的确认按钮默认在右边，而Android默认在左边。产生这种差异的原因是uni.showModal在App和小程序上调用的是原生提供的弹出框，原生平台的策略本身就不同。如果需要调整',
				showCancel: false,
				success: function(res) {
					if (res.confirm) {
						console.log('用户点击确定');
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			})
		},

		//获取项目  		
		async getMakeProjectListLib() {
			var that = this;
			var data = {};
			data['make_id'] = that.make_id;
			data['make_user_id'] = Cache.get('user_id');
			hitmatchcommon.getMakeProjectListLibMethod(data).then(res => {
				if (res) {
					that.list = res; //获取项目
				}
			});
		},
		//开始游戏
		begingame(url = '', id = '') {
			Cache.set('project_id', id); //项目ID
			uni.navigateTo({
				url: url,
			})
		},
	}
}